import java.util.Arrays;

/**
 * @author LKQ
 * @date 2022/2/2 20:38
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {10,26,30,31,47,60};
        System.out.println(Arrays.toString(solution.twoSum(nums, 40)));
    }
    public int[] twoSum(int[] nums, int target) {
        int left = 0, right = nums.length - 1;
        while (left < right) {
            int s = nums[left] + nums[right];
            if (s == target) {
                break;
            }else if (s > target) {
                right--;
            }else {
                left++;
            }
        }
        return new int[]{nums[left], nums[right]};
    }
}
